<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript">
var bjId="";
	$(function(){
		$('#dialog').dialog({
			autoOpen:false,
			title:"编辑",
			modal:true,
			width:400,
			buttons:[{
				text:'提交',
				click:function (){
					var self=$(this);
					var form=$(this).find('form');
					var params=form.serialize();
					
					$.post('student/save',params,function(data){
						refrash();
						self.dialog('close');
					})	
				}
			},{
				text:'退出',
				click:function(){
					$(this).dialog('close');
				}
			}]
		})
		refrash();

		})
		function bjChange(Id) {
			bjId=Id;
			if(bjId!=null){
			refrash();
				
			}
		}
	function refrash(){
		$('#myTable').load('student/table',{bjId:bjId},function(){
			});
	}
	function xg(id) {
		var dialog=$('#dialog');
		dialog.load('student/update',{id:id},function(){
			dialog.dialog('open');
		})
	}
	function add() {
		var dialog=$('#dialog');
		dialog.load('student/edit2',{bjId:bjId},function(){
			dialog.dialog('open');
		})
	}
	function sc(id) {
		if(confirm('是否要删除这条记录？')){
			$.post('student/delete',{id:id},function(data){
				refrash();
			})
			
		}
				
	}
	function czmm(id) {
		if(confirm('是否要重置该学生密码？')){
			$.post('student/refreshpwd',{id:id},function(data){
				refrash();
			})
			}else{
				alert('重置成功，学生默认密码为1111');
				}
	}
</script>


<h2>学生管理</h2>
<div class="aaa">
<div id="dialog" style="display: none;"></div>
	<p>
	<label>班级：</label>
	
	<select id="bj" onchange="bjChange(this.value)" >
		<option value="0" >请选择班级</option>
		<c:forEach items="${bjs}" var="bj">
			<option value="${bj.id}">${bj.name} </option>
		
		</c:forEach>	
	</select>
	</p>
<div id="myTable" >
		
	</div>
</div>